package com.usian.search.controller.v1;

import com.usian.common.dtos.ResponseResult;
import com.usian.model.article.dtos.ArticleDto;
import com.usian.model.search.dtos.UserSearchDto;
import com.usian.search.service.ApArticleSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/article/search")
public class ArticleSearchController {

    @Autowired
    private ApArticleSearchService apArticleSearchService;
     /**
     *  搜索文章
     * @param userSearchDto
     * @return
     */
    @PostMapping("/search")
    public ResponseResult<List<ArticleDto>> articleSearch(@RequestBody UserSearchDto userSearchDto) {
        List<ArticleDto> list = apArticleSearchService.esArticleSearch(userSearchDto);
        return ResponseResult.ok(list);
    }
}
